package red.stu.mc.mod.codeblock.item;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ItemLoader {
	
	public static Item itemCodeBlockKey = new ItemCodeBlockKey();
	
	public ItemLoader(FMLPreInitializationEvent event) {
		register(itemCodeBlockKey, "codeblock_key");
	}
	
	@SideOnly(Side.CLIENT)
	public void initRender() {
		registerRender(itemCodeBlockKey);
	}
	
	// register item
	private void register(Item item, String name) {
		ForgeRegistries.ITEMS.register(item.setRegistryName(name));
	}
	
	// register item Model
	private void registerRender(Item item) {
		ModelLoader.setCustomModelResourceLocation(item, 0, 
				new ModelResourceLocation(item.getRegistryName(), "inventory"));
	}
	
}
